<!DOCTYPE html>
<html>
<head>
    <title>划解分成</title>
    <#include "../inc/header.ftl"/>
    <link rel="stylesheet" href="${prefix}/assets/custom/css/main.css"/>
</head>
<body>

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <form name="PayDivideViewForm" id="PayDivideViewForm" action="queryPayDivideData" method="post">
                    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="r_tablebr">
                        <tr>
                            <td valign="top" class="r_nr">
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td align="left"><b>划款单号</b>
                                            <input name="dividebillnum" type="text" id="dividebillnum" value=""
                                                   class="r_input2" style="width:100px;"/><label for="select"></label>
                                        </td>
                                        <td>交易流水号<input type="text" id="bankaffirm" name="bankaffirm" value=""
                                                        class="r_input2" style="width:90px;"></td>
                                    </tr>
                                </table>
                                <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td class="r_title">河北省非税收入分成上化申请表</td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td align="left">行政区划：
                                            <input name="cantonname" type="text" id="cantonname" style="width:150px"
                                                   readonly="readonly" value="" class="r_input"/></td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx4">
                                    <tr>
                                        <td align="center" bgcolor="#f0f0f0">分成单位编码</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="unitcode" type="text"
                                                                                    readonly="readonly" class="r_input"
                                                                                    id="unitcode" style="width:110px;"
                                                                                    value=""/></td>
                                        <td align="center" bgcolor="#f0f0f0">分成单位名称</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="unitname" type="text"
                                                                                    readonly="readonly" id="unitname"
                                                                                    style="width:130px;" class="r_input"
                                                                                    value=""/></td>
                                        <td align="center" bgcolor="#f0f0f0">&nbsp;</td>
                                        <td align="center" bgcolor="#f0f0f0">&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td width="107" align="center" bgcolor="#f0f0f0">项目编码</td>
                                        <td width="139" align="center" bgcolor="#f0f0f0"><input name="itemcode"
                                                                                                type="text"
                                                                                                readonly="readonly"
                                                                                                id="itemcode"
                                                                                                style="width:110px;"
                                                                                                class="r_input"
                                                                                                value=""/></td>
                                        <td width="107" align="center" bgcolor="#f0f0f0">项目名称</td>
                                        <td width="152" align="center" bgcolor="#f0f0f0"><input name="itemname"
                                                                                                type="text"
                                                                                                readonly="readonly"
                                                                                                class="r_input"
                                                                                                id="itemname"
                                                                                                style="width:130px;"
                                                                                                value=""/></td>
                                        <td width="91" align="center" bgcolor="#f0f0f0">金额</td>
                                        <td width="167" align="center" bgcolor="#f0f0f0"><input name="money" type="text"
                                                                                                readonly="readonly"
                                                                                                id="money"
                                                                                                style="width:130px;"
                                                                                                class="r_input"
                                                                                                value=""/></td>
                                    </tr>
                                    <tr>
                                        <td align="center" bgcolor="#f0f0f0">付款账户名称</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="accountname" type="text"
                                                                                    id="accountname" readonly="readonly"
                                                                                    style="width:110px;" value=""
                                                                                    class="r_input"/></td>
                                        <td align="center" bgcolor="#f0f0f0">付款账号</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="accountcode" type="text"
                                                                                    id="accountcode" readonly="readonly"
                                                                                    style="width:130px;" value=""
                                                                                    class="r_input"/></td>
                                        <td align="center" bgcolor="#f0f0f0">付款银行开户行</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="bankname" type="text"
                                                                                    id="bankname" readonly="readonly"
                                                                                    style="width:130px;" value=""
                                                                                    class="r_input"/></td>
                                    </tr>
                                    <tr>
                                        <td align="center" bgcolor="#f0f0f0">收款账户名称</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="payeeaccountname" type="text"
                                                                                    id="payeeaccountname"
                                                                                    readonly="readonly"
                                                                                    style="width:110px;" value=""
                                                                                    class="r_input"/></td>
                                        <td align="center" bgcolor="#f0f0f0">收款账号</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="payeeaccountcode" type="text"
                                                                                    id="payeeaccountcode"
                                                                                    readonly="readonly"
                                                                                    style="width:130px;" value=""
                                                                                    class="r_input"/></td>
                                        <td align="center" bgcolor="#f0f0f0">收款银行开户行</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="payeebankname" type="text"
                                                                                    id="payeebankname"
                                                                                    readonly="readonly"
                                                                                    style="width:130px;" value=""
                                                                                    class="r_input"/></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="center" bgcolor="#f0f0f0">&nbsp;</td>
                                        <td align="center" bgcolor="#f0f0f0">合　　计</td>
                                        <td colspan="3" align="center" bgcolor="#f0f0f0">
                                            <table width="100%" border="1" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td width="50%" bgcolor="#FFFFFF">（大写）<span id="bigoriginfund">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                                    </td>
                                                    <td width="50%" bgcolor="#FFFFFF">（小写）<span id="originfund">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td height="40" align="right">
                                            <input type="button" name="button" id="button" class="r_button" onclick="queryPayDivideData()" value="查询单据" />
                                            <input type="button" name="paybutton" id="paybutton"  class="r_button" onclick="pay()" value="付款" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </form>
            </div><!-- /.page-content -->

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<#include "../inc/basicjs.ftl"/>
<!-- basic scripts -->
<script src="${prefix}/assets/custom/js/commonview.js"></script>

<script type="text/javascript">

    var ischeck = false;

    function pay() {
        if (!ischeck) {
            alert("请先输入划款单号，然后查询数据后再点击收款！");
            $("#dividebillnum").focus();
            ischeck = false;
            return;
        }

        $('#PayDivideViewForm').form({
            url: prefix + '/view/divide/paydividepayview',
            onSubmit:function(){
                var isValid = $(this).form('validate');
                return isValid;
            },
            success:function(data) {
                var data = eval('(' + data + ')');
                if(data.success) {
                    ischeck = false;
                    $("#originfund").html("");
                    $("#bigoriginfund").html("");
                    location=prefix+'/view/divide/paydivideview';
                }
                alert(data.msg);
            }
        });
        $('#PayDivideViewForm').submit();
    }

    function queryPayDivideData() {
        var dividebillnum = $("#dividebillnum").val();
        if (dividebillnum == "") {
            alert("请输入划款单号！");
            $("#dividebillnum").focus();
            return;
        }
        if (dividebillnum.indexOf("FC") != 0 || dividebillnum.length != 10) {
            alert("请输入正确的划款单号！");
            $("#dividebillnum").focus();
            return;
        }
        var state = [{"key": "0", "value": "查询错误"}, {"key": "1", "value": "正常"}, {
            "key": "2",
            "value": "账户类型不符"
        }, {"key": "3", "value": "已收款"}, {"key": "4", "value": "票据不可用"}];

        $.ajax({
            type: "POST",
            url: prefix + '/view/divide/queryPayDivideData',
            dataType: "json",
            data: {dividebillnum: dividebillnum},
            success: function (data) {
                if (data.success) {
                    data = new DOMParser().parseFromString(data.data, "text/xml")
                    $("#dividebillnum").val($(data).find("dividebillnum").text());
                    $("#cantonname").val($(data).find("cantonname").text());
                    $("#unitcode").val($(data).find("unitcode").text());
                    $("#unitname").val($(data).find("unitname").text());
                    $("#itemcode").val($(data).find("itemcode").text());
                    $("#itemname").val($(data).find("itemname").text());
                    $("#money").val($(data).find("money").text());
                    $("#accountname").val($(data).find("accountname").text());
                    $("#accountcode").val($(data).find("accountcode").text());
                    $("#bankname").val($(data).find("bankname").text());
                    $("#payeeaccountname").val($(data).find("payeeaccountname").text());
                    $("#payeeaccountcode").val($(data).find("payeeaccountcode").text());
                    $("#payeebankname").val($(data).find("payeebankname").text());
                    var billstate = $(data).find("billstate").text();
                    $("#originfund").html($(data).find("money").text());
                    $("#bigoriginfund").html(upDigit($(data).find("money").text()));
                    if (billstate != '1') {
                        $('#paybutton').attr('disabled', true);
                        for (var p in state) {
                            if (state[p].key == billstate) {
                                alert(state[p].value);
                            }
                        }
                    }
                        $('#paybutton').attr('disabled', false);
                        ischeck = true;
                }else{
                    alert(data.msg);
                }
            },
            error: function (XMLResponse) {
                alert('操作失败！错误信息为：' + XMLResponse.responseText);
            }
        })
    }
</script>


</body>
</html>